(function($) {
	$
			.widget(
					"ui.multipleaccordion",
					{
						options : {
							header : "> h3",
							event : "click"
						},

						_create : function() {
							this.element.addClass(
									"ui-accordion ui-widget ui-helper-reset")
									.attr("role", "tablist");
							this.headers = this.element
									.find(this.options.header)
									.addClass(
											"ui-accordion-header ui-helper-reset ui-state-default ui-corner-all");
							this.headers.attr("role", "tab").next().attr(
									"role", "tabpanel");
							this._setupEvents(this.options.event);
						},

						_destroy : function() {
							this.element.removeClass(
									"ui-accordion ui-widget ui-helper-reset")
									.removeAttr("role");
							this.headers
									.removeAttr("role")
									.removeClass(
											"ui-accordion-header ui-helper-reset ui-state-default ui-corner-all");
							this.headers.next().removeAttr("role");
						},

						_setupEvents : function(event) {
							var events = {};
							if (!event) {
								return;
							}
							$.each(event.split(" "),
									function(index, eventName) {
										events[eventName] = "_eventHandler";
									});
							this._on(this.headers, events);
						},

						_eventHandler : function(event) {
							event.preventDefault();
							this._toggle(event);
						},

						_toggle : function(data) {
							$(data.currentTarget).next().toggle();
						}
					});
	$.extend($.ui.multipleaccordion, {
		instances : []
	});
})(jQuery);